package com.wsd.smartcarwasher.dao;

import com.wsd.smartcarwasher.domain.Coupon;
import org.apache.ibatis.annotations.Select;
import org.apache.shiro.dao.DataAccessException;

import java.util.List;

public interface CouponDao {

    int addCoupon(Coupon coupon) throws DataAccessException;

    Coupon getCouponByCouponId(int couponId) throws DataAccessException;

    @Select("SELECT * FROM coupon c\n" +
            " where FIND_IN_SET(#{machineId},c.availableMachines) and `status`=3 and partnerId is not null order by startTime limit 1")
    Coupon getCouponByMachine(Integer machineId) throws DataAccessException;

    @Select("SELECT * FROM coupon c\n" +
            " where partnerId=#{partnerId} and  status != 1   order by `time` desc")
    List<Coupon> getCouponByPartnerId(Integer partnerId) throws DataAccessException;

    int deleteCoupon(int couponId) throws DataAccessException;

    List<Coupon> queryAllCoupons() throws DataAccessException;

    List<Coupon> queryStoreCoupons(int partnerId) throws DataAccessException;

    Coupon getCouponsByCode(String couponCode)throws DataAccessException;

    Coupon getCouponsByNewB();

    int updateCouponNum(Integer couponId);

    int updateCoupon(Coupon couponUpdate);

    int updateCouponCode(Coupon coupon);
}
